package legumes.shared.domain;

import java.io.Serializable;
import java.util.Date;

/**
 * Just for transport (Data Transfert Object), to avoid to keep the password in
 * client memory.
 * 
 */
public class CustomerDTO implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private long creationDate = new Date().getTime();
	private long lastConnectionDate = -1;
	private String name;
	private String email;
	private String roles;
	private String lastConnectionAddr;
	
	public CustomerDTO(Customer c_) {
		setCreationDate(c_.getCreationDate());
		setLastConnectionDate(c_.getLastConnectionDate());
		setLastConnectionAddr(c_.getLastConnectionAddr());
		setName(c_.getName());
		setEmail(c_.getEmail());
		setRoles(c_.getRoles());
	}


	public String getLastConnectionAddr() {
		return lastConnectionAddr;
	}

	public void setLastConnectionAddr(String lastConnectionAddr_) {
		lastConnectionAddr = lastConnectionAddr_;
	}
	
	public String getRoles() {
		return roles;
	}

	public CustomerRole getRolesAsEnum() {
		return CustomerRole.valueOf(getRoles());
	}

	public void setRoles(CustomerRole role_) {
		setRoles(role_.toString());
	}

	public void setRoles(String toStringCustomerRole_) {
		roles = toStringCustomerRole_;
	}

	public CustomerDTO() {
	}

	public long getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(long creationDate) {
		this.creationDate = creationDate;
	}

	public long getLastConnectionDate() {
		return lastConnectionDate;
	}

	public void setLastConnectionDate(long lastConnectionDate) {
		this.lastConnectionDate = lastConnectionDate;
	}

	@Override
	public String toString() {
		return getEmail();
	}

	public String toFullString() {
		return "[Customer email=" + email + " name=" + getName()
				+ " creationDate=" + getCreationDate() + " lastConnectionDate"
				+ getLastConnectionDate() + "]";
	}

	public String getName() {
		return name;
	}

	private void setName(String name) {
		this.name = name;
	}

	public String getEmail() {
		return email;
	}

	private void setEmail(String email) {
		this.email = email;
	}

}
